﻿@using Webdiyer.WebControls.Mvc;
@using Zor_Tools;
@{
    Layout = null;
}

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>GIS预览</title>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
    </style>
    <script src="~/Content/Scripts/learunui-framework.js"></script>
    <script src="~/Content/Scripts/jquery/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=http://api.map.baidu.com/api?v=2.0&ak=to1sjHDvE74iNOpQsRGHYPuAtXyxMno1"></script>
</head>
<body>
    <div id="allmap"></div>
    <script type="text/javascript">
        //获取社区经纬度
        var CommunityLonAndLat;
        getAjax("/Warning/CommunityLongitudeAndLatitude", "", function (data) {
            CommunityLonAndLat =data;
        })

        //获取街道办社区名称
        var StrName;
        getAjax("/Warning/CommunityName", "", function (data) {          
            StrName = data;
        })

        var arrMeg = new Array();
        var strMeg;
        var accordionJson, html;
        $(function () {        
            getAjax("/Warning/GetMap", "", function (data) {
                accordionJson = eval("(" + data + ")");              
                $.each(accordionJson, function (i) {

                    strMeg = {
                        lag: accordionJson[i].Bd_Longitude,
                        lng: accordionJson[i].Bd_Latitude,
                        name: accordionJson[i].Bd_Name,
                        uim:accordionJson[i].UimNumber,
                        ground: accordionJson[i].Bd_Ground,
                        aname: accordionJson[i].Bd_Aname,
                        number: accordionJson[i].Number,
                        tax: accordionJson[i].xiaoji*0.01,
                        qiye: accordionJson[i].qiyeNum,
                        geren: accordionJson[i].gerenNum

                    };                
                    arrMeg.push(strMeg);                 
                });
            })
        });        
        // 百度地图API功能
        var map = new BMap.Map("allmap");          // 创建地图实例     
        var Lon = 0.00000;
        var Lat = 0.00000;
        var c=  CommunityLonAndLat.split(',');
        Lon = c[0];
        Lat = c[1];
        map.centerAndZoom(new BMap.Point(Lon, Lat), 17); // 创建点坐标
       // map.enableScrollWheelZoom();                // 初始化地图，设置中心点坐标和地图级别

        //添加社区楼宇信息
           
        function getBoundary()
        {
            for (var i = 0; i < arrMeg.length; i++) {
                createIco(arrMeg[i]);             
            }
        }
                                     
        //创建标注
        function createIco(dome) {

            //创建标注
            var myIcon = new BMap.Icon("../Content/Images/buliding.png", new BMap.Size(25, 25));
            ////解析经纬度
            //var lag1 = dome.lag.substring(0,3); 
            //var lag2 = dome.lag.substring(3,7);
            //var Longitude = lag1 + "." + lag2; //经度
            //var lng1 = dome.lng.substring(0,2);
            //var lng2 = dome.lng.substring(2,6);
            //var Latitude = lng1 + "." + lng2; //纬度
            //var point = new BMap.Point(Longitude, Latitude);
        

            var point = new BMap.Point(dome.lag, dome.lng);
            var marker = new BMap.Marker(point, { icon: myIcon });  // 创建标注
            map.addOverlay(marker);              				//将标注添加到地图中
            marker.setAnimation(BMAP_ANIMATION_DROP); 			//动画
             
            //设置弹出信息
            var sContent =
            "<h4 style='margin:0 0 5px 0;padding:0.2em 0;font-family:微软雅黑'>" + dome.name + "</h4>" +
            "<div style='float:left;width:220px; height:2px;background:#EE7600;'></div></br>" +
            "<p style='margin:0;line-height:2.0;font-size:13px;'>" +
            "楼体信息：" + dome.ground + "层," + dome.uim + "个单元," + dome.number + "户</br>" +
            "征税信息：" + dome.tax + "元</br>" +
            "出租情况：企业公司" + dome.qiye + "户,个人" + dome.geren + "户</br>" +
            "管理人员：" + dome.aname + "</br>" +
            "</p>";

            var infoWindow = new BMap.InfoWindow(sContent);  // 创建信息窗口对象
            marker.addEventListener("click", function () {
                map.openInfoWindow(infoWindow, point); 		 //开启信息窗口
            });

            //设置标签
            var label = new BMap.Label(dome.name, { offset: new BMap.Size(30, 2) });
            label.setStyle({
                border: "0px",
                backgroundColor: "#FF8000",
                fontFamily: "微软雅黑",
                fontSize: "14px"
            });
            marker.setLabel(label);
        }

        setTimeout(function () {
            getBoundary();
        }, 1);
    </script>
</body>
</html>